using System;
using UnityEngine;
using Unity.VisualScripting;
using ResourceApplySuccessEventArgs = UnityGameFramework.Runtime.ResourceApplySuccessEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Resource Apply")]
    [UnitSurtitle("Success")]
    public sealed class ResourceApplySuccess : FrameworkEventUnit<ResourceApplySuccessEventArgs>
    {
        protected override int EventId => ResourceApplySuccessEventArgs.EventId;
        protected override string HookName => UGFHookNames.ResourceApplySuccess;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Name
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput ApplyPath
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput ResourcePackPath
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Length
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput CompressedLength
        {
            get;
            private set;
        }


        protected override void Definition()
        {
            base.Definition();
            Name = ValueOutput<string>(nameof(Name));
            ApplyPath = ValueOutput<string>(nameof(ApplyPath));
            ResourcePackPath = ValueOutput<string>(nameof(ResourcePackPath));
            Length = ValueOutput<int>(nameof(Length));
            CompressedLength = ValueOutput<int>(nameof(CompressedLength));
        }

        protected override void AssignArguments(Flow flow, ResourceApplySuccessEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(Name, args.ResourcePackPath);
            flow.SetValue(ApplyPath, args.ResourcePackPath);
            flow.SetValue(Length, args.Length);
            flow.SetValue(CompressedLength, args.CompressedLength);
        }
    }
}